-
Notifications
You must be signed in to change notification settings - Fork 72
CBL-6240: Align with server SQL++ reserved words #2386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
When parsing a query in SQL++, we log a warning if an (unquoted) identifier is reserved in the server.
|
Code Coverage Results:
|
| } | ||
|
|
||
| constexpr const char* kServerReservedWords = | ||
| "ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove ADVISE ALTER ANALYZE BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CLUSTER
|
|
||
| constexpr const char* kServerReservedWords = | ||
| "ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER " | ||
| "COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove COLLECTION COMMIT COMMITTED CONNECT CONTINUE CREATE
| constexpr const char* kServerReservedWords = | ||
| "ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER " | ||
| "COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT" | ||
| " CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove CYCLE DATABASE DATASET DATASTORE DECLARE DELETE DROP
| "COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT" | ||
| " CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT " | ||
| "ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS" | ||
| " FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove FLUSH FTS GOLANG GSI
| " CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT " | ||
| "ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS" | ||
| " FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT " | ||
| "INDEX INFER INLINE INSERT INTERSECT INTO ISOLATION JAVASCRIPT KEY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove INSERT INTO JAVASCRIPT
| "ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS" | ||
| " FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT " | ||
| "INDEX INFER INLINE INSERT INTERSECT INTO ISOLATION JAVASCRIPT KEY" | ||
| " KEYS KEYSPACE KNOWN LANGUAGE LAST LATERAL LET LETTING LEVEL LSM MAP MAPPING MATCHED MATERIALIZED " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove LANGUAGE
| "PRECEDING PREPARE PREV PREVIOUS PREVVAL PRIMARY PRIVATE PRIVILEGE PROBE PROCEDURE PUBLIC" | ||
| " RANGE RAW READ REALM RECURSIVE REDUCE RENAME REPLACE RESPECT RESTART RESTRICT RETURN RETURNING REVOKE " | ||
| "ROLE ROLES ROLLBACK ROW ROWS SAVEPOINT SCHEMA SCOPE SELF SEMI SEQUENCE" | ||
| " SET SHOW SOME START STATISTICS STRING SYSTEM TIES TO TRAN TRANSACTION TRIGGER TRUNCATE UNBOUNDED UNDER " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove SET TRANSACTION
| const char* p = kServerReservedWords; | ||
| const char* start = nullptr; | ||
| for ( ; *p != '\0'; ++p ) { | ||
| if ( *p == ' ' ) { | ||
| if ( start != nullptr ) { | ||
| //start -> p | ||
| serverReserved.emplace(start, p); | ||
| start = nullptr; | ||
| } | ||
| } else if ( start == nullptr ) { | ||
| start = p; | ||
| } | ||
| } | ||
| if ( start != nullptr ) { serverReserved.emplace(start, p); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use split() for this instead of nasty C code:
/** Splits the string at occurrences of `separator` and calls the callback for each piece.
There may be empty pieces, if the separator occurs at the start or end or twice in a row. */
void split(std::string_view str, std::string_view separator, fleece::function_ref<void(std::string_view)> callback);You'll need a consistent delimiter between words though, probably a single space.
| static bool isServerReservedWord(std::string word); | ||
|
|
||
| static string warnOnServerReservedWord(const char* input) { | ||
| if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in the Server SQL++)", input); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in the Server SQL++)", input); } | |
| if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in Server SQL++)", input); } |
When parsing a query in SQL++, we log a warning if an (unquoted) identifier is reserved in the server.